package com.vercon.common.network;

import io.reactivex.Observer;


/**
 * Subscriber基类,可以在这里处理client网络连接状况
 * （比如没有wifi，没有4g，没有联网等）
 * Created by fcn-mq on 2017/4/19.
 */

public abstract class MyObserve<T> implements Observer<T> {

    /*private Context context;

    public MySubscriber(Context context) {
        this.context = context;
    }*/


    public abstract void onNetError(Throwable e);


    @Override
    public void onComplete() {

    }

    @Override
    public void onError(Throwable e) {
        onNetError(e);
        //  Log.e("tag","MySubscriber.throwable ="+e.toString());
        //  Log.e("tag","MySubscriber.throwable ="+e.getMessage());
//        EventBus.getDefault().post(new NoNetEvent());
        if (e instanceof Exception) {
            //访问获得对应的Exception
//            onError(ExceptionHandle.handleException(e));
        } else {
            //将Throwable 和 未知错误的status code返回
//            onError(new ExceptionHandle.ResponeThrowable(e, ExceptionHandle.ERROR.UNKNOWN));
        }
    }


}
